<template>
  <page-tab-list
    url="/SyDangerCheckTaskDetail/GetPageData"
    :params="params"
    @initList="_initList"
  >
    <van-cell v-for="(item, index) in list" :key="index" class="card">
      <van-tag v-if="item.CheckResult == 'N'" class="info_tag" type="danger"
        >不符合</van-tag
      >
      <van-tag v-if="item.CheckResult == 'Y'" class="info_tag" type="normal"
        >符　合</van-tag
      >
      <van-tag v-if="item.CheckResult == 'NA'" class="info_tag" type="warning"
        >不适用</van-tag
      >
      <div class="warn_item">
        <div @click="goDetail(item)">
          <div class="warn_header">
            <div>{{ index + 1 }}、隐患描述：{{ item.HiddenDangerDesc }}</div>
          </div>
          <van-row gutter="20" class="dep_sort">
            <van-col span="24">
              <img
                src="@/assets/Images/AppIcon/icon_list_kind.png"
                class="icon"
              />所属任务：{{ item.CheckTaskName }}</van-col
            >
          </van-row>

          <van-row gutter="20" class="dep_sort">
            <van-col>
              <img
                src="@/assets/Images/AppIcon/icon_list_type.png"
                class="icon"
              />{{
                item.OriginType == 1
                  ? "检查表检查"
                  : item.OriginType == 2
                  ? "依据检查"
                  : "随手拍"
              }}<span
                class="color-blue"
                @click="openCheckTemplateView(item, $event)"
                >{{ item.TName ? "（" + item.TName + "）" : "" }}</span
              ></van-col
            >
          </van-row>

          <van-row class="dep_sort">
            <van-col span="24">
              <img
                src="@/assets/Images/AppIcon/icon_list_type.png"
                class="icon"
              />{{ "隐患区域：" + (item.HiddenDangerArea || "无") }}</van-col
            >
          </van-row>

          <van-row class="dep_sort">
            <van-col span="8">
              <img
                src="@/assets/Images/AppIcon/icon_list_user.png"
                class="icon"
              />{{ item.CreateChnName }}</van-col
            >
            <van-col span="16">
              <img
                src="@/assets/Images/AppIcon/icon_list_date.png"
                class="icon"
              />{{ item.CreateDate | formatDateTime)}}</van-col
            >
          </van-row>
        </div>
      </div>
    </van-cell>
  </page-tab-list>
</template>

<script>
import PageTabList from "@/components/PageTabList/PageTabList.vue";

export default {
  components: { PageTabList },
  data() {
    return {
      list: [],
      params: [
        {
          dataType: "BeSubmited",
          title: "已提交的记录",
          ctCode: this.$route.query.ctCode,
        },
        {
          dataType: "NotSubmit",
          title: "未提交的记录",
          ctCode: this.$route.query.ctCode,
        },
        {
          dataType: "BeBacked",
          title: "被退回的记录",
          ctCode: this.$route.query.ctCode,
        },
      ],
    };
  },
  created() {
    this.calcTitle();
  },
  methods: {
    _initList(list) {
      this.list = list;
    },
    calcTitle() {
      this.ctCode = this.$route.query.ctCode;
      if (this.ctCode) {
        this.$store.commit("updateTitle", "任务检查记录");
      } else {
        this.$store.commit("updateTitle", "我的检查历史");
      }
    },
    // 详情
    goDetail(item) {
      if (item.Status < 20) {
        this.$router.push({
          path: "/SytechDanger/DangerCheckTaskDetailEdit",
          query: { id: item.ID },
        });
      } else {
        this.$router.push({
          path: "/SytechDanger/DangerCheckDetailView",
          query: { id: item.ID, type: "submited" },
        });
      }
    },
    openCheckTemplateView(item, ev) {
      this.$router.push({
        path: "/SytechDanger/DangerTemplateCheckResult",
        query: {
          tCode: item.TCode,
          tRand: item.TRand,
          ctCode: this.$route.query.ctCode,
        },
      });
      ev.cancelBubble = true;
    },
  },
};
</script>
